import Vue from 'vue'
import VueI18n from 'vue-i18n'
import Cookies from 'js-cookie'
import elementEnLocale from 'element-ui/lib/locale/lang/en'
import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN'
import elementThLocale from 'element-ui/lib/locale/lang/th'
import enLocale from './en'
import zhLocale from './zh'
import thLocale from './th'

Vue.use(VueI18n)

const messages = {
  'zh': {
    ...zhLocale,
    ...elementZhLocale
  },
  'en': {
    ...enLocale,
    ...elementEnLocale
  },
  'th': {
    ...thLocale,
    ...elementThLocale
  }
}

// 创建 i18n 实例
export const i18n = new VueI18n({
  locale: Cookies.get('language') || 'zh',
  fallbackLocale: 'zh',
  messages,
  silentTranslationWarn: true
})

export default i18n
